package com.konne.nightmare.FastPublicOpinion.ui.information.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.blankj.utilcode.util.SizeUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.konne.nightmare.FastPublicOpinion.R;
import com.konne.nightmare.FastPublicOpinion.base.BaseMvpFragment;
import com.konne.nightmare.FastPublicOpinion.base.BaseMvpPresenter;
import com.konne.nightmare.FastPublicOpinion.utils.LoadProgressDialog;
import com.konne.nightmare.FastPublicOpinion.widget.CourseView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;

/**
 * Create by ws.
 * on Data:2022/2/12  Time:下午 3:26.
 * description: 资料库导入 .
 */
public class DatabaseListFragment extends BaseMvpFragment {
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    private List<Database> datas;

    public static DatabaseListFragment getInstance() {
        return new DatabaseListFragment();
    }

    @Override
    protected BaseMvpPresenter createPresenter() {
        return new BaseMvpPresenter();
    }

    @Override
    public LoadProgressDialog getLoadDialog() {
        return null;
    }

    @Override
    public void cancelLoadDialog() {

    }

    @Override
    public int getLayout() {
        return R.layout.frag_database_list;
    }

    @Override
    public void initView() {
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        datas = new ArrayList<>();//数据应用model层获取，p层传递。这里模拟省略了
        datas.add(new Database("高等数学","数学五班"));
        datas.add(new Database("高等数学","数学五班"));
        datas.add(new Database("高等数学","数学五班"));
        datas.add(new Database("高等数学","数学五班"));
        recyclerView.setAdapter(new DatabaseAdapter(datas));
    }

    class DatabaseAdapter extends BaseQuickAdapter<Database, BaseViewHolder> {
        public DatabaseAdapter(@Nullable List<Database> data) {
            super(R.layout.item_course, data);
        }

        @Override
        protected void convert(BaseViewHolder helper, Database item) {
            ImageView iv_pic = helper.getView(R.id.iv_pic);
            iv_pic.setImageResource(R.drawable.ic_database);
            helper.setText(R.id.tv_title, item.title)
                    .setText(R.id.tv_sub_title, item.className);
            helper.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                }
            });
        }
    }

    class Database {
        String title;
        String className;

        public Database(String title, String className) {
            this.title = title;
            this.className = className;
        }
    }
}
